package me.zhengjie.org.teamemployee.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.hr.employeebase.domain.EmployeeBase;
import me.zhengjie.org.teambase.domain.TeamBase;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @author ZGZ
* @date 2020-04-14
*/
@Entity
@Data
@Table(name="team_employee")
public class TeamEmployee implements Serializable {

    /** ID */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    /** 人员 */
//    @Column(name = "emp_id")
    //    private Integer empId;
//    @OneToOne
//    @JoinColumn(name = "emp_id")
//    private EmployeeBase empId;
    @Column(name = "emp_id")
    private Integer empId;
    @OneToOne
    @JoinColumn(name = "emp_id", insertable = false, updatable = false)
    private EmployeeBase employeeBase;

    /** 组织 */
//    @Column(name = "team_id")
//    private Integer teamId;
//    @OneToOne
//    @JoinColumn(name = "team_id")
//    private TeamBase teamId;
    @Column(name = "team_id")
    private Integer teamId;
    @OneToOne
    @JoinColumn(name = "team_id", insertable = false, updatable = false)
    private TeamBase teamBase;

    /** 开始时间 */
    @Column(name = "start_time")
    private Timestamp startTime;

    /** 结束时间 */
    @Column(name = "end_time")
    private Timestamp endTime;

    /** 变动说明 */
    @Column(name = "`describe`")
    private String describe;

    public void copy(TeamEmployee source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}